home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 8
/
008.d81
/
pps #17
< prev
next >
Wrap
Text File
|
2022-08-26
|
4KB
|
209 lines
PEEKs, POKEs, and SYSes -- part 17
by Jimmy Weiler
======================================
Location: 53248 Hexadecimal:$D000
Official Label: VIC Type:RAM
Useful BASIC commands: PEEK, POKE
--------------------------------------
VIC is the acronym for the Commodore's
Video Interface Controller Chip.
The range of memory we are interested
in is 53248 to 53294 ($D000 to $D02E).
These locations control (among other
things) sprites and the video screen.
It is customary to set the variable
'V' to 53248 in a program and refer to
these addresses as V plus an offset,
so that's how we'll talk about them in
this article, too.
(... like this... LET V = 53248)
( POKE V + 21,0)
We'll start by talking about
sprites. 'Sprite' is short for
'Movable Object Block' (don't ask).
They're called MOB's because each
sprite is a small piece of memory (a
block) that represents an image of
some object. That image can be moved
to any location on the screen.
The VIC chip takes care of the hard
part -- putting the image on the
screen. All you have to do is design
the image and tell VIC which sprite it
is, where to find the image, where to
put the image, what color the image
is, what size to make the image, and
whether to put it in front of or
behind the text. Simple, right?
That's why we're covering it in this
series.
Let's deal with each of these items
singly. First, 'design the image'.
Sprite design is at best a tedious
process. At worst, it is pure
drudgery. If you have Commodore's
Disk Bonus Pack, use the SPRITE EDITOR
program on it. If you don't have it,
pay close attention.
I hope you understand binary, bits,
and bytes. Otherwise none of this
will make much sense.
A sprite image is defined by a piece
of memory 63 bytes long. The image is
3 bytes wide and 21 bytes tall. Each
bit in the image represents a single
pixel in the unexpanded sprite. When
the image appears on the screen the
bytes are laid out like this:
--------------------------
! byte01 ! byte02 ! byte03 !
! byte04 ! byte05 ! byte06 !
.
etc.
.
! byte55 ! byte56 ! byte57 !
! byte58 ! byte59 ! byte60 !
! byte61 ! byte62 ! byte63 !
--------------------------
The bits are arranged like this:
--------------------------
! byte01 ! byte02 ! byte03 !
!76543210!76543210!76543210!
Ok, got all that? Now let's make a
sprite that looks like an umbrella.
76543210 76543210 76543210
-------- -------- --------
1 ! *!********!* ! 3
4 ! ****!********!**** ! 6
7 ! *******!********!******* ! 9
10 !********!********!********! 12
13 ! ! ** ! ! 15
16 ! ! ** ! ! 18
19 ! ! ** ! ! 21
22 ! ! ** ! ! 24
25 ! ! ** ! ! 27
28 ! ! ** ! ! 30
31 ! ! ** ! ! 33
34 ! ! ** ! ! 36
37 ! ! ** *!* ! 39
40 ! ! ****! ! 42
43 ! ! ! ! 45
46 ! ! ! ! 48
...the rest of the bytes (49 to 63)
are blanks (zeros).
Now, jot down the value of each of the
bytes in that chart: (Let's put them
in data statements so we can keep
better track of them.)
50 DATA 1,255,128,15,255,240,127,255,
254,255,255,255,0,24,0,0,24,0,0,24,0
60 DATA 0,24,0,0,24,0,0,24,0,0,24,0
0,24,0,0,25,128,0,15,0,0,0,0,0,0,0,0,
70 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0
OK, now let's put that data into
a block of memory (remember, we're
dealing with movable object BLOCKs
here).
80 FOR BL = 832 to 832 + 62
90 READ D
100 POKE BL,D
110 NEZT BL
There!! The data has been POKEd into
part of the cassette input buffer and
we're done designing the sprite's
shape.
-------- Continued in Part 18 --------